#coding=utf-8
'''
3.8. Calculating with Fractions
fractions module
'''
from fractions import Fraction
a = Fraction(5, 4)
b = Fraction(7, 16)
print(a + b)

c = a * b
print(c)
print(c.numerator)    # 分子
print(c.denominator)  # 分母
print(float(c))
print(c.limit_denominator(8))

x = 3.75
y = Fraction(*x.as_integer_ratio())
print(y)